<?php

use yii\db\Migration;

class m161206_060528_reply extends Migration
{
    public function up()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
        }
        
        $this->createTable('{{%reply}}', [
            'id' => $this->primaryKey(),
            'comment_id' => $this->integer()->notNull(),
            'reply' => $this->string(),
            'status' => $this->integer(1)->notNull()->defaultValue(1),
            'created_at' => $this->integer()->notNull(),
            'updated_at' => $this->integer()->notNull(),
        ], $tableOptions);
        
        $this->createIndex('idx-reply-comment_id', 'reply', 'comment_id');
        
        $this->createIndex('idx-reply-created_at_id', 'reply', 'created_at');
    }

    public function down()
    {
        echo "m161206_060528_reply cannot be reverted.\n";

        return false;
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    PublicClass function safeUp()
    {
    }

    PublicClass function safeDown()
    {
    }
    */
}
